Skip to content

PER-10670: Switch to vitest#789

Merged
liam-lloyd merged 1 commit into
mainfrom
noissue_switch_to_vitest
Jul 14, 2026
Merged

PER-10670: Switch to vitest#789
liam-lloyd merged 1 commit into
mainfrom
noissue_switch_to_vitest

Conversation

@liam-lloyd

@liam-lloyd liam-lloyd commented Jun 26, 2026

Copy link
Copy Markdown
Member

Jest doesn't officially support ESM. We'd like to move this repo to ESM,
as that appears to be the way of the future (and we have some
dependencies that in their latest releases only offer ESM support). To
that end, this commit replaces Jest with Vitest.

@liam-lloyd liam-lloyd marked this pull request as draft June 26, 2026 22:01
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.22%. Comparing base (3b4f217) to head (88baf22).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #789      +/-   ##
==========================================
- Coverage   98.56%   98.22%   -0.34%     
==========================================
  Files         109       93      -16     
  Lines        2783     2364     -419     
  Branches      463      439      -24     
==========================================
- Hits         2743     2322     -421     
- Misses         36       42       +6     
+ Partials        4        0       -4     
Flag Coverage Δ
api 98.22% <ø> (-0.34%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@liam-lloyd liam-lloyd force-pushed the noissue_switch_to_vitest branch 6 times, most recently from 58d42f9 to d9ddc4a Compare July 7, 2026 17:53
@liam-lloyd liam-lloyd marked this pull request as ready for review July 7, 2026 17:59
@liam-lloyd liam-lloyd changed the title Switch to vitest - WIP PER-10670: Switch to vitest Jul 7, 2026
@liam-lloyd

Copy link
Copy Markdown
Member Author

The codecov difference here seems to come from differences in how jest and vitest count coverage, not from any actual reduction in coverage.

@liam-lloyd liam-lloyd force-pushed the noissue_switch_to_vitest branch 2 times, most recently from b5ba73c to 03b784a Compare July 7, 2026 21:16

@cecilia-donnelly cecilia-donnelly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks straightforward and the tests are passing. I have a question about the import setup inline.

@@ -1,5 +1,6 @@
import request from "supertest";
import { when } from "jest-when";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we imported these from jest in some central location and have to import them in each file from vitest -- is that expected?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a difference in philosophy between jest and vitest. Jest imported a bunch of stuff automatically, vitest wants you to be explicit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@cecilia-donnelly

Copy link
Copy Markdown
Member

Some Claude review comments:

- packages/event_utils lost its jest.config.js with no vitest.config.ts replacement — dormant since it has no tests yet, but will break  path-alias resolution the moment one is added.
- AGENTS.md still tells contributors to use jest-when, which was removed from package.json in favor of vitest-when.
-  a duplicated hand-rolled @stela/logger mock in trigger_archivematica instead of the new shared mock, vitest-mock-extended added  separately in 6 package.json files instead of hoisted at root, coverage.clean: false risking stale coverage output, and the old silent:   true Jest option having no Vitest equivalent (noisier CI logs).

@liam-lloyd

Copy link
Copy Markdown
Member Author

Some Claude review comments:

- packages/event_utils lost its jest.config.js with no vitest.config.ts replacement — dormant since it has no tests yet, but will break  path-alias resolution the moment one is added.
- AGENTS.md still tells contributors to use jest-when, which was removed from package.json in favor of vitest-when.
-  a duplicated hand-rolled @stela/logger mock in trigger_archivematica instead of the new shared mock, vitest-mock-extended added  separately in 6 package.json files instead of hoisted at root, coverage.clean: false risking stale coverage output, and the old silent:   true Jest option having no Vitest equivalent (noisier CI logs).

I think it's correct for event_utils to not have a vitest config if it doesn't have tests. I've fixed the other things noted here (except the last one, which doesn't have a fix)

@liam-lloyd liam-lloyd force-pushed the noissue_switch_to_vitest branch 4 times, most recently from a5f2a86 to 1980c41 Compare July 13, 2026 23:50
@cecilia-donnelly

Copy link
Copy Markdown
Member

Looks like something that changed broke some of the tests unfortunately.

@liam-lloyd liam-lloyd force-pushed the noissue_switch_to_vitest branch 2 times, most recently from d3020b0 to 6e70650 Compare July 14, 2026 18:56
Comment thread AGENTS.md Outdated
- **Database:** PostgreSQL, accessed via TinyPg (SQL file-based query library)
- **Authentication:** FusionAuth (external identity provider)
- **Testing:** Jest with ts-jest, Supertest, jest-when, nock, jest-mock-extended
- **Testing:** Vitest, Supertest, vitest-when, nock, jest-mock-extended

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super tiny, but this still has jest-mock-extended in the list, which presumably is now some vitest equivalent.

@liam-lloyd liam-lloyd force-pushed the noissue_switch_to_vitest branch from 6e70650 to 10329d2 Compare July 14, 2026 19:19

@cecilia-donnelly cecilia-donnelly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo!

Jest doesn't officially support ESM. We'd like to move this repo to ESM,
as that appears to be the way of the future (and we have some
dependencies that in their latest releases only offer ESM support). To
that end, this commit replaces Jest with Vitest.
@liam-lloyd liam-lloyd force-pushed the noissue_switch_to_vitest branch from 10329d2 to 88baf22 Compare July 14, 2026 20:05
@liam-lloyd liam-lloyd merged commit f4ebf7f into main Jul 14, 2026
33 checks passed
@liam-lloyd liam-lloyd deleted the noissue_switch_to_vitest branch July 14, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants